package xhwl.insurance.db;


import android.content.Context;

import com.lidroid.xutils.DbUtils;
import com.lidroid.xutils.db.sqlite.Selector;
import com.lidroid.xutils.exception.DbException;

import java.util.ArrayList;
import java.util.List;

import xhwl.insurance.db.bean.SalePicInfo;


/**
* 升级模块数据库操作类
* @author lim
* @date 2017年2月9日
* @version 1.0
*/
public class SalePicInfoDao extends BaseDao<SalePicInfo> {

    public SalePicInfoDao(Context context) {
        super(context, DbConstant.SaleInfo.DB_NAME, DbConstant.SaleInfo.DB_VERSION);
        // TODO Auto-generated constructor stub
    }
    @Override
	public void onUpgrade(DbUtils db, int oldVersion, int newVersion) {
//        if(oldVersion==1&&newVersion==2){
//            try {
//                db.execNonQuery("alter table "+DbConstant.Upgrade.DB_NAME+" add "+DbConstant.Upgrade.COLUMN_FORCE_FLAG+" text default 0");
//            } catch (DbException e) {
//                e.printStackTrace();
//            }
//
//        }
    }
    @Override
    public SalePicInfo find(String versionCode) {
        // TODO Auto-generated method stub
        return null;
    }
    public List<SalePicInfo> getListBySaleId(int saleId){
        List<SalePicInfo> records=new ArrayList<>();
        if(saleId>0){
            try {
                records = db.<SalePicInfo>findAll(Selector.from(SalePicInfo.class).where(
                        DbConstant.SalePicInfo.COLUMN_SALE_ID, "=", saleId));
            } catch (DbException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        return records;
    }
}

